<template>
  <div class="DetailsBasicInformation">
    <Form @submit.native.prevent>
      <Row :gutter="20">
        <Col span="12" v-if="unlocking('客户管理', '2000017')">
          <FormItem label="置业目的：" @keyup.enter.native="keyupEnterFun()">
            <span v-if="type != 'purposeOwnershipVal'">{{ztCustomerIntention.intentionPurpose | intentionPurpose}}</span>
            <Select id="formDealWithRefs" v-if="type == 'purposeOwnershipVal'" v-model="purposeOwnershipVal" filterable style="width:200px" placeholder="请选择置业目的" >
              <Option v-for="(item, index) in purposeOwnershipList" :value="item.val" :key="index">{{ item.name }}</Option>
            </Select>
            <img v-if="type != 'purposeOwnershipVal' && unlocking('客户管理', '3000005')" class="editFeatures" @click="FormDealWithFun('purposeOwnershipVal')" src="@img/edit.png">
          </FormItem>
        </Col>
        <Col span="12" v-if="unlocking('客户管理', '2000018')">
          <FormItem label="置业阶段：" @keyup.enter.native="keyupEnterFun()">
            <span v-if="type != 'HomeOwnershipStageVal'">{{ztCustomerIntention.housePurchasingPhase == 1 ? '出发筹备' : ztCustomerIntention.housePurchasingPhase == 2 ? '看盘比盘' : ztCustomerIntention.housePurchasingPhase == 3 ? '选盘选房' : '-'}}</span>
            <Select id="formDealWithRefs" v-if="type == 'HomeOwnershipStageVal'" v-model="HomeOwnershipStageVal" filterable style="width:200px" placeholder="请选择置业阶段">
              <Option v-for="(item, index) in HomeOwnershipStageList" :value="item.val" :key="index">{{ item.name }}</Option>
            </Select>
            <img v-if="type != 'HomeOwnershipStageVal' && unlocking('客户管理', '3000005')" class="editFeatures" @click="FormDealWithFun('HomeOwnershipStageVal')" src="@img/edit.png">
          </FormItem>
        </Col>
        <Col span="12" v-if="unlocking('客户管理', '2000019')">
          <FormItem label="意向区域：" @keyup.enter.native="keyupEnterFun()">
            <span v-if="type != 'IntentAreaVal'">{{ztCustomerIntention.intentionCityRegionName || '-'}}</span>
            <Select id="formDealWithRefs" v-if="type == 'IntentAreaVal'" v-model="IntentAreaVal" filterable multiple style="width:200px" placeholder="请选择意向区域" >
              <Option v-for="(item, index) in IntentAreaListData" :value="item.cityCode" :key="index">{{item.cityName}}</Option>
            </Select>
            <img v-if="type != 'IntentAreaVal' && unlocking('客户管理', '3000005')" class="editFeatures" @click="FormDealWithFun('IntentAreaVal')" src="@img/edit.png">
          </FormItem>
        </Col>
        <Col span="12" v-if="unlocking('客户管理', '2000020')">
          <FormItem label="意向户型：" @keyup.enter.native="keyupEnterFun()">
            <span v-if="type != 'IntentionTypeVal'">{{(intentionHouseTypeName&&intentionHouseTypeName.substr(0, intentionHouseTypeName.length - 1)) || '-'}}</span>
            <Select id="formDealWithRefs" v-if="type == 'IntentionTypeVal'" v-model="IntentionTypeVal" filterable multiple style="width:200px" placeholder="请选择意向户型" >
              <Option v-for="(item, index) in IntentionTypeList" :value="item.val" :key="index">{{ item.name }}</Option>
            </Select>
            <img v-if="type != 'IntentionTypeVal' && unlocking('客户管理', '3000005')" class="editFeatures" @click="FormDealWithFun('IntentionTypeVal')" src="@img/edit.png">
          </FormItem>
        </Col>
        <Col span="12" v-if="unlocking('客户管理', '2000021')">
          <FormItem label="首选户型：" @keyup.enter.native="keyupEnterFun()">
            <span v-if="type != 'PreferredApartmentVal'">{{firstChoiceHouseTypeName || '-'}}</span>
            <Select id="formDealWithRefs" v-if="type == 'PreferredApartmentVal'" v-model="PreferredApartmentVal" filterable multiple style="width:200px" placeholder="请选择首选户型" >
              <Option v-for="(item, index) in IntentionTypeList" :value="item.val" :key="index">{{ item.name }}</Option>
            </Select>
            <img v-if="type != 'PreferredApartmentVal' && unlocking('客户管理', '3000005')" class="editFeatures" @click="FormDealWithFun('PreferredApartmentVal')" src="@img/edit.png">
          </FormItem>
        </Col>
        <Col span="12" v-if="unlocking('客户管理', '2000022')">
          <FormItem label="意向业态：" @keyup.enter.native="keyupEnterFun()">
            <span v-if="type != 'IntentionFormatVal'">{{(intentionHouseFloorName&&intentionHouseFloorName.substr(0, intentionHouseFloorName.length - 1)) || '-'}}</span>
            <Select id="formDealWithRefs" v-if="type == 'IntentionFormatVal'" v-model="IntentionFormatVal" filterable multiple style="width:200px" placeholder="请选择意向业态" >
              <Option v-for="(item, index) in IntentionFormatList" :value="item.val" :key="index">{{ item.name }}</Option>
            </Select>
            <img v-if="type != 'IntentionFormatVal' && unlocking('客户管理', '3000005')" class="editFeatures" @click="FormDealWithFun('IntentionFormatVal')" src="@img/edit.png">
          </FormItem>
        </Col>
        <Col span="12" v-if="unlocking('客户管理', '2000025')">
          <FormItem label="对比竞品：" @keyup.enter.native="keyupEnterFun('CompareCompetingProductsVal')">
            <span v-if="type != 'CompareCompetingProductsVal'">{{ztCustomerIntention.contrastCompetition || '-'}}</span>
            <Input id="formDealWithRefs" v-if="type == 'CompareCompetingProductsVal'" v-model="CompareCompetingProductsVal" placeholder="请输入对比竞品" style="width: 200px" />
            <img v-if="type != 'CompareCompetingProductsVal' && unlocking('客户管理', '3000005')" class="editFeatures" @click="FormDealWithFun('CompareCompetingProductsVal')" src="@img/edit.png">
          </FormItem>
        </Col>
        <Col span="12" v-if="unlocking('客户管理', '2000024')">
          <FormItem label="对比区域：" @keyup.enter.native="keyupEnterFun()">
            <span v-if="type != 'ContrastAreaVal'">{{ztCustomerIntention.contrastRegionName || '-'}}</span>
            <Select id="formDealWithRefs" v-if="type == 'ContrastAreaVal'" v-model="ContrastAreaVal" filterable multiple style="width:200px" placeholder="请选择对比区域" >
              <Option v-for="(item, index) in IntentAreaListData" :value="item.cityCode" :key="index">{{item.cityName}}</Option>
            </Select>
            <img v-if="type != 'ContrastAreaVal' && unlocking('客户管理', '3000005')" class="editFeatures" @click="FormDealWithFun('ContrastAreaVal')" src="@img/edit.png">
          </FormItem>
        </Col>
        <Col span="12" v-if="unlocking('客户管理', '2000026')">
          <FormItem label="首付预算：" @keyup.enter.native="keyupEnterFun('DownPaymentBudgetMin-DownPaymentBudgetMax')">
            <span v-if="type != 'DownPaymentBudget'">{{ztCustomerIntention.downPaymentBudget && ztCustomerIntention.downPaymentBudget[0].start}}-{{ztCustomerIntention.downPaymentBudget && ztCustomerIntention.downPaymentBudget[0].end}}万</span>
            <span id="formDealWithRefs" v-if="type == 'DownPaymentBudget'">
              <Input v-model="DownPaymentBudgetMin" type="number" style="width:90px" placeholder="请输入"></Input>
              <span style="margin: 0 6px;">-</span>
              <Input v-model="DownPaymentBudgetMax" type="number" style="width:90px" placeholder="请输入"></Input>
            </span>
            <img v-if="type != 'DownPaymentBudget' && unlocking('客户管理', '3000005')" class="editFeatures" @click="FormDealWithFun('DownPaymentBudget')" src="@img/edit.png">
          </FormItem>
        </Col>
        <Col span="12" v-if="unlocking('客户管理', '2000039')">
          <FormItem label="单价预算：" @keyup.enter.native="keyupEnterFun('UnitPriceBudgetList')">
            <span v-if="type != 'UnitPriceBudgetList' && UnitPriceBudgetList">
                {{UnitPriceBudgetList.split("-")[0] == 0?`${UnitPriceBudgetList.split("-")[1]}元/㎡以下`:UnitPriceBudgetList.split("-")[1] == 999999999?`${UnitPriceBudgetList.split("-")[0]}元/㎡以上`:`${UnitPriceBudgetList.split("-")[0]}-${UnitPriceBudgetList.split("-")[1]}元/㎡`}}
            </span>
            <span id="formDealWithRefs" v-if="type == 'UnitPriceBudgetList'">
              <Select v-model="UnitPriceBudgetList" filterable style="width:200px" placeholder="请选择单价预算" >
                  <Option v-for="(item, index) in priceList" :value="`${item.paramValues.start}-${item.paramValues.end}`" :key="index" >
                    {{item.paramValues.start == 0?`${item.paramValues.end}元/㎡以下`:item.paramValues.end == 999999999?`${item.paramValues.start}元/㎡以上`:`${item.paramValues.start}-${item.paramValues.end}元/㎡`}}
                  </Option>
              </Select>
            </span>
            <img v-if="type != 'UnitPriceBudgetList' && unlocking('客户管理', '3000005')" class="editFeatures" @click="FormDealWithFun('UnitPriceBudgetList')" src="@img/edit.png">
          </FormItem>
        </Col>
        <Col span="12" v-if="unlocking('客户管理', '2000027')">
          <FormItem label="总价预算：" @keyup.enter.native="keyupEnterFun('TotalPriceBudget')">
            <span v-if="type != 'TotalPriceBudget' &&  TotalPriceBudget">
                {{TotalPriceBudget.split("-")[0] == 0?`${TotalPriceBudget.split("-")[1]}万元以下`:TotalPriceBudget.split("-")[1] == 999999999?`${TotalPriceBudget.split("-")[0]}万元以上`:`${TotalPriceBudget.split("-")[0]}-${TotalPriceBudget.split("-")[1]}万元`}}
            </span>
            <span id="formDealWithRefs" v-if="type == 'TotalPriceBudget'">
              <Select v-model="TotalPriceBudget" filterable style="width:200px" placeholder="请选择总价预算" >
                <Option v-for="(item, index) in totalPriceList" :value="`${item.paramValues.start}-${item.paramValues.end}`" :key="index" >
                   {{item.paramValues.start == 0?`${item.paramValues.end}万元以下`:item.paramValues.end == 999999999?`${item.paramValues.start}万元以上`:`${item.paramValues.start}-${item.paramValues.end}万元`}}
                </Option>
              </Select>
            </span>
            <img v-if="type != 'TotalPriceBudget' && unlocking('客户管理', '3000005')" class="editFeatures" @click="FormDealWithFun('TotalPriceBudget')" src="@img/edit.png">
          </FormItem>
        </Col>
        <Col span="12" v-if="unlocking('客户管理', '2000040')">
          <FormItem label="意向地铁：" @keyup.enter.native="keyupEnterFun()">
            <span v-if="type != 'intentSubwayVal'">{{intentSubwayName || '-'}}</span>
            <Select id="formDealWithRefs" v-if="type == 'intentSubwayVal'" v-model="intentSubwayVal" filterable style="width:200px" placeholder="请选择意向地铁" >
              <Option v-for="(item, index) in intentSubwayValList" :value="item.metroId" :key="index">{{ item.metroName }}</Option>
            </Select>
            <img v-if="type != 'intentSubwayVal' && unlocking('客户管理', '3000005')" class="editFeatures" @click="FormDealWithFun('intentSubwayVal')" src="@img/edit.png">
          </FormItem>
        </Col>
        <Col span="12" v-if="unlocking('客户管理', '2000028')">
          <FormItem label="意向环线：" @keyup.enter.native="keyupEnterFun()">
            <span v-if="type != 'circleIntentVal'">{{ztCustomerIntention.intentionLoopLineName || '-'}}</span>
            <Select id="formDealWithRefs" v-if="type == 'circleIntentVal'" v-model="circleIntentVal" filterable style="width:200px" placeholder="请选择意向环线" >
              <Option v-for="(item, index) in circleIntentValList" :value="item.loopLineId" :key="index">{{ item.loopLineName }}</Option>
            </Select>
            <img v-if="type != 'circleIntentVal' && unlocking('客户管理', '3000005')" class="editFeatures" @click="FormDealWithFun('circleIntentVal')" src="@img/edit.png">
          </FormItem>
        </Col>
        <Col span="12" v-if="unlocking('客户管理', '2000038')">
          <FormItem label="意向面积：" @keyup.enter.native="keyupEnterFun('IntentArea')">
            <!-- <span v-if="type != 'IntentArea'">{{IntentAreaName || '-'}}</span> -->
            <span v-if="type != 'IntentArea' && IntentArea">
              <span  v-for="(item,index) in IntentArea" :key="index">
                 {{item.split("-")[0] == 0?`${item.split("-")[1]}㎡以下`:item.split("-")[1] == 999999999?`${item.split("-")[0]}㎡以上`:`${item.split("-")[0]}-${item.split("-")[1]}㎡`}}
                  <span v-if="index < IntentArea.length-1">,</span>
              </span>
            </span>
            <span id="formDealWithRefs" v-if="type == 'IntentArea'" >
              <Select v-model="IntentArea" multiple filterable style="width:200px" placeholder="请选择意向面积" >
                 <Option v-for="(item, index) in areaList" :value="item.searchParamId" :key="index" >
                   {{item.paramValues.start == 0?`${item.paramValues.end}㎡以下`:item.paramValues.end == 999999999?`${item.paramValues.start}㎡以上`:`${item.paramValues.start}-${item.paramValues.end}㎡`}}
                </Option>
              </Select>
            </span>
            <img v-if="type != 'IntentArea' && unlocking('客户管理', '3000005')" class="editFeatures" @click="FormDealWithFun('IntentArea')" src="@img/edit.png">
          </FormItem>
        </Col>
        <Col span="12" v-if="unlocking('客户管理', '2000033')">
          <FormItem label="认可点：" @keyup.enter.native="keyupEnterFun()">
            <span v-if="type != 'RecognitionPointVal'">{{(RecognitionPointValName&&RecognitionPointValName.substr(0, RecognitionPointValName.length - 1)) || '-'}}</span>
            <Select id="formDealWithRefs" v-if="type == 'RecognitionPointVal'" v-model="RecognitionPointVal" filterable multiple style="width:200px" placeholder="请选择认可点" >
              <Option v-for="(item, index) in RecognitionPointList" :value="item.val" :key="index">{{ item.name }}</Option>
            </Select>
            <img v-if="type != 'RecognitionPointVal' && unlocking('客户管理', '3000005')" class="editFeatures" @click="FormDealWithFun('RecognitionPointVal')" src="@img/edit.png">
          </FormItem>
        </Col>
        <Col span="12" v-if="unlocking('客户管理', '2000031')">
          <FormItem label="付款方式：" @keyup.enter.native="keyupEnterFun()">
            <span v-if="type != 'paymentMethodVal'">{{ztCustomerIntention.paymentType == 1 ? '一次性付款' : ztCustomerIntention.paymentType == 2 ? '商业贷款' : ztCustomerIntention.paymentType == 3 ? '公积金贷款' : ztCustomerIntention.paymentType == 4 ? '组合贷款' : ztCustomerIntention.paymentType == 5 ? '分期付款' : '-'}}</span>
            <Select id="formDealWithRefs" v-if="type == 'paymentMethodVal'" v-model="paymentMethodVal" filterable style="width:200px" placeholder="请选择付款方式" >
              <Option v-for="(item, index) in paymentMethodList" :value="item.val" :key="index">{{ item.name }}</Option>
            </Select>
            <img v-if="type != 'paymentMethodVal' && unlocking('客户管理', '3000005')" class="editFeatures" @click="FormDealWithFun('paymentMethodVal')" src="@img/edit.png">
          </FormItem>
        </Col>
        <Col span="12" v-if="unlocking('客户管理', '2000035')">
          <FormItem label="考虑因素：" @keyup.enter.native="keyupEnterFun()">
            <span v-if="type != 'ConsiderationsVal'">{{ztCustomerIntention.considerFactor || '-'}}</span>
            <Input id="formDealWithRefs" v-if="type == 'ConsiderationsVal'" v-model="ConsiderationsVal" placeholder="请输入考虑因素" style="width: 200px" />
            <img v-if="type != 'ConsiderationsVal' && unlocking('客户管理', '3000005')" class="editFeatures" @click="FormDealWithFun('ConsiderationsVal')" src="@img/edit.png">
          </FormItem>
        </Col>
        <Col span="12" v-if="unlocking('客户管理', '2000032')">
          <FormItem label="付款比例：" @keyup.enter.native="keyupEnterFun('PaymentRatioVal')">
            <span v-if="type != 'PaymentRatioVal'">{{ztCustomerIntention.paymentRatio || '-'}}%</span>
            <Input id="formDealWithRefs" v-if="type == 'PaymentRatioVal'" v-model="PaymentRatioVal" placeholder="请输入付款比例" style="width: 200px" />
            <img v-if="type != 'PaymentRatioVal' && unlocking('客户管理', '3000005')" class="editFeatures" @click="FormDealWithFun('PaymentRatioVal')" src="@img/edit.png">
          </FormItem>
        </Col>
        <Col span="12" v-if="unlocking('客户管理', '2000034')">
          <FormItem label="抗性点：" @keyup.enter.native="keyupEnterFun()">
            <span v-if="type != 'ResistancePointVal'">{{(ResistancePointValName&&ResistancePointValName.substr(0, ResistancePointValName.length - 1)) || '-'}}</span>
            <Select id="formDealWithRefs" v-if="type == 'ResistancePointVal'" v-model="ResistancePointVal" filterable multiple style="width:200px" placeholder="请选择抗性点" >
              <Option v-for="(item, index) in RecognitionPointList" :value="item.val" :key="index">{{ item.name }}</Option>
            </Select>
            <img v-if="type != 'ResistancePointVal' && unlocking('客户管理', '3000005')" class="editFeatures" @click="FormDealWithFun('ResistancePointVal')" src="@img/edit.png">
          </FormItem>
        </Col>
        <Col span="12" v-if="unlocking('客户管理', '2000036')">
          <FormItem label="要点备注：" @keyup.enter.native="keyupEnterFun('KeyNotesVal')">
            <span v-if="type != 'KeyNotesVal'">{{ztCustomerIntention.intentionRemark}}</span>
            <Input id="formDealWithRefs" v-if="type == 'KeyNotesVal'" type="textarea" v-model="KeyNotesVal" placeholder="请输入要点备注" style="width: 200px" />
            <img v-if="type != 'KeyNotesVal' && unlocking('客户管理', '3000005')" class="editFeatures" @click="FormDealWithFun('KeyNotesVal')" src="@img/edit.png">
          </FormItem>
        </Col>
      </Row>
    </Form>
  </div>
</template>
<script>
  import { customerDetailsInfo, cityBaselist, customeruserEdit, metroList, looplinePage } from "@/api/customerManagement.js";
  import { getSelectedAllList} from "@/api/cityConfig"
  export default {
    components: {
    },
    filters:{
      intentionPurpose(value){
        let flag = '-';
        switch(value - 0){
          case 1:
           flag = "自住";
          break;
          case 2:
           flag = "投资";
          break;
          case 3:
           flag = "自主兼投资";
          break;
          case 4:
           flag = "刚需";
          break;
          case 5:
           flag = "结婚";
          break;
          case 6:
           flag = "养老";
          break;
          case 7:
           flag = "改善";
          break;
          case 8:
           flag = "教育";
          break;
          case 9:
           flag = "投资";
          break;
        }
        return flag;
      }
    },
    props: ['servicePersonnelId'],
    data() {
      return {
        intentionId: '',
        ResistancePointValName: '',
        intentionCityRegionName: '',
        firstChoiceHouseTypeName: '',
        intentionHouseTypeName: '',
        intentionHouseFloorName: '',
        ztCustomerIntention: '',
        circleIntentValList: [],
        intentSubwayValList: [],
        type: '',
        purposeOwnershipVal: '',
        purposeOwnershipList: [{name: '请选择', val: '-4'}, {name: '自住', val: '1'}, {name: '投资', val: '2'}, {name: '自住兼投资', val: '3'}],
        HomeOwnershipStageVal: '',
        HomeOwnershipStageList: [{name: '请选择', val: '-4'}, {name: '出发筹备', val: '1'}, {name: '看盘比盘', val: '2'}, {name: '选盘选房', val: '3'}],
        IntentAreaVal: [],
        IntentAreaName:'',
        IntentAreaListData: [],
        IntentionTypeVal: [],
        IntentionTypeList: [{name: '一室', val: '1'}, {name: '二室', val: '2'}, {name: '三室', val: '3'}, {name: '四室', val: '4'}, {name: '五室及以上', val: '5'}],
        PreferredApartmentVal: '',
        IntentionFormatVal: [],
        IntentionFormatList:  [{name: '高层', val: '1'}, {name: '别墅', val: '2'}, {name: '多层', val: '3'}, {name: '公寓', val: '4'}, {name: '商业', val: '5'}],
        CompareCompetingProductsVal: '',
        ContrastAreaVal: [],
        DownPaymentBudgetMin: '',
        DownPaymentBudgetMax: '',

        UnitPriceBudgetList: '',
        TotalPriceBudget: '',
        IntentArea:[],
        RecognitionPointVal: [],
        RecognitionPointValName: '',
        RecognitionPointList: [{name: '区域发展潜力', val: '1'}, {name: '区域自然环境', val: '2'}, {name: '区域人文环境', val: '3'}, {name: '地铁', val: '4'}, {name: '学区', val: '5'}, {name: '周边商业配套', val: '6'}, {name: '周边医疗配套', val: '7'}, {name: '客户圈层', val: '8'}, {name: '发展商品牌', val: '8'}, {name: '楼盘品质', val: '10'}, {name: '物业管理品牌', val: '11'}, {name: '推荐房源满意度', val: '12'}, {name: '交付时间', val: '13'}],
        propertyUnderNameList: [{name: '请选择', val: '-4'}, {name: '无房产', val: '0'}, {name: '有1套', val: '1'}, {name: '有2套', val: '2'}, {name: '有3套', val: '3'}, {name: '有4套', val: '4'}, {name: '有5套', val: '5'}, {name: '有5套以上', val: '-1'}],
        paymentMethodVal: '',
        paymentMethodList:  [{name: '请选择', val: '-4'}, {name: '一次性付款', val: '1'}, {name: '商业贷款', val: '2'}, {name: '公积金贷款', val: '3'}, {name: '组合贷款', val: '4'}, {name: '分期付款', val: '5'}],
        ConsiderationsVal: '',
        PaymentRatioVal: '',
        ResistancePointVal: '',
        KeyNotesVal: '',
        intentSubwayVal: '',
        intentSubwayName:'',
        circleIntentVal: '',
        priceList:[],
        totalPriceList:[],
        areaList:[]
      }
    },
    methods: {
      // 编辑功能
      FormDealWithFun(type) {
        if (!this.servicePersonnelId.storeManager) {
          this.$Message.warning('您无操作权限，请联系系统管理员')
          return false
        }
        this.initData()
        this.type = type
      },
      // 回车事件
      keyupEnterFun(val) {
         console.log(22222,val)
        if (val == 'CompareCompetingProductsVal') {
          if (this.CompareCompetingProductsVal) {
            console.log(this.CurrentResidentialArea,"*************************************");
            if (this.CompareCompetingProductsVal && this.CompareCompetingProductsVal.length > 50) {
              this.$Message.warning('不可超过50个字符')
              return false
            }
          }
        }
        //首付预算
        if (val == 'DownPaymentBudget') {
          if (val.split('-')[0]) {
            if (!(/^[1-9]\d*$/.test(this.DownPaymentBudgetMin)) || !(/^[1-9]\d*$/.test(this.DownPaymentBudgetMax))) {
              this.$Message.warning('请输入正整数')
              return false
            }  else if (this.DownPaymentBudgetMin >= this.DownPaymentBudgetMax) {
              this.$Message.warning('右侧值必须大于左侧输入值')
              return false
            }
          }
          // if (val.split('-')[1]) {
          //   if (!(/^[1-9]\d*$/.test(this[val.split('-')[1]]))) {
          //     this.$Message.warning('请输入正整数')
          //     return false
          //   }  else if (parseFloat(this[val.split('-')[0]]) >= parseFloat(this[val.split('-')[1]])) {
          //     this.$Message.warning('右侧值必须大于左侧输入值')
          //     return false
          //   }
          // }
        }
        if (val == 'PaymentRatioVal') {
          if (this.PaymentRatioVal) {
            if (!(/^[1-9]\d*$/.test(this.PaymentRatioVal))) {
              this.$Message.warning('请输入正整数')
              return false
            }
          }
        }
        if (val == 'KeyNotesVal') {
          if (this.KeyNotesVal) {
            if (this.KeyNotesVal.length > 500) {
              this.$Message.warning('不可超过500个字符')
              return false
            }
          }
        }
        let {intentionArea,totalBudget,unitPriceBudget} = this.ztCustomerIntention;
        console.log("this.ResistancePointVal",this.ResistancePointVal)
        let parms = {
          userCustomerId: this.$route.query.userCustomerId,
          intentionId: this.intentionId,
          buildingId: this.servicePersonnelId.buildingId,
          intentionPurpose: this.purposeOwnershipVal == -4 ? '' : this.purposeOwnershipVal,
          housePurchasingPhase: this.HomeOwnershipStageVal == -4 ? '' : this.HomeOwnershipStageVal,
          intentionRegion: this.IntentAreaVal.join(","),
          intentionHouseType: this.IntentionTypeVal.join(","),
          firstChoiceHouseType: this.PreferredApartmentVal.join(","),
          intentionProduct: this.IntentionFormatVal.join(","),
          contrastCompetition: this.CompareCompetingProductsVal,
          contrastRegion: this.ContrastAreaVal.join(","),
          downPaymentBudget: JSON.stringify([{start: this.DownPaymentBudgetMin,end: this.DownPaymentBudgetMax}]),
          unitPriceBudget: JSON.stringify(unitPriceBudget),
          totalBudget: JSON.stringify(totalBudget),
          intentionSubway: this.intentSubwayVal,
          intentionLoopLine: this.circleIntentVal,
          intentionArea: intentionArea,
          approvePoints: this.RecognitionPointVal.join(","),
          paymentType: this.paymentMethodVal,
          considerFactor: this.ConsiderationsVal,
          paymentRatio: this.PaymentRatioVal,
          resistancePoints: Array.isArray(this.ResistancePointVal)?this.ResistancePointVal.join(","):this.ResistancePointVal,
          intentionRemark: this.KeyNotesVal
        }
        //面积
         console.log(val,this.IntentArea)
        if(val === 'IntentArea' && this.IntentArea.length>0){
           parms.intentionArea =  this.IntentArea.join(",")
        }
        //总价
        if(val === 'TotalPriceBudget' && this.TotalPriceBudget){
           let str = this.TotalPriceBudget.split("-");
           parms.totalBudget = JSON.stringify([{start:str[0],end:str[1]}]);
        }
        console.log("单价预算·········",this.UnitPriceBudget);
        //单价
        if(val === 'UnitPriceBudgetList' && this.UnitPriceBudgetList){
          
           let str = this.UnitPriceBudgetList.split("-");
           
          parms.unitPriceBudget =JSON.stringify([{start:str[0],end:str[1]}]);
        }
        this.type = ''
        customeruserEdit(parms).then(res=>{
          this.$Message.success('修改成功!');
          this.initData()
        }).catch(err=>{
          this.$Message.error(err)
        })
      },
      // 点击页面
      documentDealWithFun(e) {
        const contextMenuBox = document.getElementById("formDealWithRefs");
        if (!e.target.classList.contains('editFeatures')) {
          if (contextMenuBox){
            if(!contextMenuBox.contains(e.target)) {
              this.keyupEnterFun(this.type)
            }
          }
        }
      },
      // 初始化获取数据
      async initData() {
        // 城市地铁信息
        await metroList({
          cityCode: this.servicePersonnelId.cityCode
        }).then(res=>{
          if (res && res.list) {
            this.intentSubwayValList = res.list
          } else {
            this.intentSubwayValList = []
          }
        }).catch(err=>{
          this.$Message.error(err)
        })
        // 城市环线信息
        await looplinePage({
          cityCode: this.servicePersonnelId.cityCode
        }).then(res=>{
          if (res && res.list) {
            this.circleIntentValList = res.list
          } else {
            this.circleIntentValList = []
          }
        }).catch(err=>{
          this.$Message.error(err)
        })
        // 获取置业报告
        customerDetailsInfo({
          userCustomerId: this.$route.query.userCustomerId
        }).then(res=>{
          if (res) {
            console.log("获取置业报告返回值",res)
            res.downPaymentBudget = (res.downPaymentBudget&&JSON.parse(res.downPaymentBudget)) || ''

            res.unitPriceBudget = (res.unitPriceBudget&&JSON.parse(res.unitPriceBudget)) || []
            res.totalBudget = (res.totalBudget&&JSON.parse(res.totalBudget)) || []
            //res.intentionArea = (res.intentionArea&&JSON.parse(res.intentionArea)) || []

            this.ztCustomerIntention = res
            this.intentionId = res.intentionId
            // 数据返填
            this.purposeOwnershipVal = res.intentionPurpose == 1 ? '1' : res.intentionPurpose == 2 ? '2' : res.intentionPurpose == 3 ? '3' : ''
            res.intentionCityRegionName = ""
            if (res.intentionRegion) {
              res.intentionRegion.split(',').forEach((item) => {
                this.IntentAreaListData.forEach((items) => {
                  if (items.cityCode == item) {
                    res.intentionCityRegionName += items.cityName + ','
                  }
                })
              })
            }
            this.IntentAreaVal = res.intentionRegion ? res.intentionRegion.split(',') : []

            this.HomeOwnershipStageVal = res.housePurchasingPhase == 1 ? '1' : res.housePurchasingPhase == 2 ? '2' : res.housePurchasingPhase == 3 ? '3' : ''
            this.intentionHouseTypeName = ''
            if (res.intentionHouseType) {
              res.intentionHouseType.split(',').map((item) => {
                this.IntentionTypeList.map((items) => {
                  if (item == items.val) {
                    this.intentionHouseTypeName += items.name + ','
                  }
                })
              })
            } else {
              this.intentionHouseTypeName = ''
            }
            console.log("首选户型",res.firstChoiceHouseType,'意向户型',res.intentionHouseType,this.IntentionTypeList)
    
            this.IntentionTypeVal = (res.intentionHouseType && res.intentionHouseType.split(',')) || []
            this.firstChoiceHouseTypeName = ''
            if (res.firstChoiceHouseType) {
              res.firstChoiceHouseType.split(',').map((item) => {
                this.IntentionTypeList.map((items) => {
                  if (item == items.val) {
                    this.firstChoiceHouseTypeName += items.name + ','
                  }
                })
              })
            } else {
              this.firstChoiceHouseTypeName = ''
            }
            console.log("首选户型名字",this.firstChoiceHouseTypeName)
            this.PreferredApartmentVal = (res.firstChoiceHouseType && res.firstChoiceHouseType.split(',')) || []
            this.intentionHouseFloorName = ''
            if (res.intentionProduct) {
              res.intentionProduct.split(',').map((item) => {
                this.IntentionFormatList.map((items) => {
                  if (item == items.val) {
                    this.intentionHouseFloorName += items.name + ','
                  }
                })
              })
            } else {
              this.intentionHouseFloorName = ''
            }
            //对面积 单价预算  总价预算
            let {unitPriceBudget, totalBudget,more} = res;
            console.log(res,"------------------",more)
            this.IntentArea = []
            unitPriceBudget && unitPriceBudget.map(item=>this.UnitPriceBudgetList = `${item.start}-${item.end}`)
            totalBudget && totalBudget.map(item=>this.TotalPriceBudget = `${item.start}-${item.end}`)
            more &&  more.intentionArea && more.intentionArea.map(item=>this.IntentArea.push(`${item.start}-${item.end}`))
            this.IntentAreaName = this.IntentArea.join(",")
            // res.IntentAreaName = ''
            // console.log("++++++++++++++",res.intentionArea);
            // if(res.intentionArea && res.intentionArea!=null &&res.intentionArea.length > 0){
            //   res.intentionArea.forEach((items)=>{
            //       this.areaList.forEach((item)=>{
            //         if(items == item.searchParamId){
            //           res.IntentAreaName += item.start +'-'+item.end+','
            //         }
            //     })
            //   })
            // }
            // this.IntentArea = res.intentionArea&&res.intentionArea || []

            this.IntentionFormatVal = (res.intentionProduct && res.intentionProduct.split(',')) || []
            this.CompareCompetingProductsVal = res.contrastCompetition
            this.ContrastAreaVal = (res.contrastRegion && res.contrastRegion.split(',')) || []
            res.contrastRegionName = ""
            if (res.contrastRegion) {
              res.contrastRegion.split(',').forEach((item) => {
                this.IntentAreaListData.forEach((items) => {
                  if (items.cityCode == item) {
                    res.contrastRegionName += items.cityName + ','
                  }
                })
              })
            }
            this.circleIntentVal = res.intentionLoopLine
            res.intentionLoopLineName = ""
            if (res.intentionLoopLine) {
              this.circleIntentValList.forEach((item) => {
                if (item.loopLineId == res.intentionLoopLine) {
                  res.intentionLoopLineName = item.loopLineName
                }
              })
            }
            this.DownPaymentBudgetMin = (res.downPaymentBudget&&res.downPaymentBudget[0]&&res.downPaymentBudget[0].start) || ''
            this.DownPaymentBudgetMax = (res.downPaymentBudget&&res.downPaymentBudget[0]&&res.downPaymentBudget[0].end) || ''
            this.ResistancePointValName = ''
            if (res.resistancePoints) {
              console.log("数据格式————————————————————",res.resistancePoints);
              res.resistancePoints.split(",").map((item) => {
                this.RecognitionPointList.map((items) => {
                  if (item == items.val) {
                    this.ResistancePointValName += items.name + ','
                  }
                })
              })
            } else {
              this.ResistancePointValName = ''
            }
            this.ResistancePointVal = (res.resistancePoints && res.resistancePoints) || []
             //认可点
            this.RecognitionPointValName = '';
            console.log("认可点3333333333")
            if (res.approvePoints) {
              res.approvePoints.split(',').map((item) => {
                this.RecognitionPointList.map((items) => {
                  if (item == items.val) {
                    this.RecognitionPointValName += items.name + ','
                  }
                })
              })
            } else {
              this.RecognitionPointValName = ''
            }
            console.log("=====认可点=======",this.RecognitionPointValName)
            // 意向地铁
            if(res.intentionSubway) {
              this.intentSubwayVal = res.intentionSubway
              this.intentSubwayValList.map(item =>{
                if(this.intentSubwayVal == item.metroId) {
                  console.log(900000000000000000,item.metroName);
                  this.intentSubwayName = item.metroName
                }
              })
            }
            this.RecognitionPointVal = (res.approvePoints && res.approvePoints.split(',')) || []
            this.paymentMethodVal = res.paymentType == 1 ? '1' : res.paymentType == 2 ? '2' : res.paymentType == 3 ? '3' : res.paymentType == 4 ? '4' : res.paymentType == 5 ? '5' : ''
            this.ConsiderationsVal = res.considerFactor
            this.PaymentRatioVal = res.paymentRatio
            this.KeyNotesVal = res.intentionRemark
          }
        }).catch(err=>{
          try {
             console.log("++++++++++++++++++++++++++++++++",err);
             throw (err);
          } catch (res) {
             console.log("+++------------------+",err);
             throw (res);
          }
          //this.$Message.error(err.toString())
        })
        // 获取楼盘所有行政区域
        cityBaselist({
          level: 4,
          parentCode: this.servicePersonnelId.cityCode
        }).then(res=>{
          if (res && res.list) {
            this.IntentAreaListData = res.list
          } else {
            this.IntentAreaListData = []
          }
        }).catch(err=>{
          this.$Message.error(err)
        })
        this.getSelectedAll()
      },
       //获取 面积 单价 总价筛选条件
      getSelectedAll(){
        getSelectedAllList({cityCode: this.servicePersonnelId.cityCode,platform: 3}).then(res=>{
          if (res) {
            this.priceList = res.averagePrice || []
            this.totalPriceList = res.totalPrice || []
            this.areaList = res.area || []
          }
        })
      }
    },
    computed: {

    },
    created() {
      // 初始化获取数据
      this.initData()
    },
    mounted() {
      document.addEventListener('click', this.documentDealWithFun)
    },
    destroyed() {
      document.removeEventListener('click', this.documentDealWithFun)
    },
    watch: {

    },
  }
</script>
<style lang="scss" scoped>
  .DetailsBasicInformation{
    .ivu-form-item{
      margin-bottom: 4px;
    }
    .editFeatures{
      vertical-align: middle;
      margin-left: 20px;
      cursor: pointer;
      display: inline-block;
    }
  }
</style>
